package com.zhu.responder.websocker.controller;

import com.zhu.responder.websocker.handler.ChannelPool;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@RequestMapping("/send")
public class sendController {

    @GetMapping("/ws")
    public void ws() throws Exception{
        while (true){
            TextWebSocketFrame textWebSocketFrame = new TextWebSocketFrame(String.valueOf(new Random().nextInt(10000)));
            ChannelPool.channels.writeAndFlush(textWebSocketFrame);
            Thread.sleep(5000);
        }
    }
}